﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Smart.Data
{
    /// <summary>
    /// Excel 97-2003 数据源实现类
    /// </summary>
    public class ExcelDataSource : DataSource
    {
        public ExcelDataSource()
            : this(
                System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "dbdemo.xls")) { }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="model">文件路径</param>
        public ExcelDataSource(string model)
        {
            Model = model;
            Provider = "System.Data.OleDb";
            FormatString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties='Excel 8.0; HDR=YES; IMEX=1'";
        }

        public override string ToConnectionString()
        {
            return string.Format(FormatString, Model);
        }
    }
}
